{layout name="../../admin/view/layout/main" /}
<div class="card">
    <div class="card-body">
        <div><span class="badge bg-info"><span class="mdi mdi-cog-outline"></span> 自定义数据权限：</span></div>
        <div id="types-tree" style="background: #f8f8f8; padding: 10px; margin-top: 5px;"></div>
    </div>
</div>
<script>
    $(function (){
        $('#types-tree').jstree({
            'core' : {
                'themes' : {
                    'responsive': false
                },
                'data' : {$tree|raw},
            },
            'plugins' : ['types', 'checkbox'],
        });
        $('#types-tree').on('ready.jstree', function (){
            $('#types-tree').on("changed.jstree", function (e, data) {
                $.post("{:url('system/role/dept')}", {id: {$role.id}, arr: data.selected}, function(res){
                    // 设置完成
                    layer.msg('设置成功', {
                        icon: 'success',
                    });
                });
            });
        });
    })
</script>